using System;
using System.Windows.Forms;

namespace WaterQualityReportSystem
{
    /// <summary>
    /// 设备状态选择对话框
    /// </summary>
    public partial class DeviceStatusSelectionDialog : Form
    {
        private ListBox listBoxStatus;
        private Button btnOK;
        private Button btnCancel;
        private Label lblTitle;
        private Label lblDescription;

        public string SelectedStatus { get; private set; } = string.Empty;

        public DeviceStatusSelectionDialog()
        {
            InitializeComponent();
            LoadStatusData();
        }

        private void InitializeComponent()
        {
            this.listBoxStatus = new ListBox();
            this.btnOK = new Button();
            this.btnCancel = new Button();
            this.lblTitle = new Label();
            this.lblDescription = new Label();
            this.SuspendLayout();

            // 
            // lblTitle
            // 
            this.lblTitle.AutoSize = true;
            this.lblTitle.Font = new System.Drawing.Font("Microsoft YaHei", 12F, System.Drawing.FontStyle.Bold);
            this.lblTitle.Location = new System.Drawing.Point(12, 9);
            this.lblTitle.Name = "lblTitle";
            this.lblTitle.Size = new System.Drawing.Size(200, 21);
            this.lblTitle.TabIndex = 0;
            this.lblTitle.Text = "选择设备状态进行模拟";

            // 
            // lblDescription
            // 
            this.lblDescription.AutoSize = true;
            this.lblDescription.Location = new System.Drawing.Point(12, 40);
            this.lblDescription.Name = "lblDescription";
            this.lblDescription.Size = new System.Drawing.Size(350, 17);
            this.lblDescription.TabIndex = 1;
            this.lblDescription.Text = "请选择要模拟的设备状态，系统将生成相应的状态响应数据：";

            // 
            // listBoxStatus
            // 
            this.listBoxStatus.FormattingEnabled = true;
            this.listBoxStatus.ItemHeight = 17;
            this.listBoxStatus.Location = new System.Drawing.Point(12, 70);
            this.listBoxStatus.Name = "listBoxStatus";
            this.listBoxStatus.Size = new System.Drawing.Size(450, 200);
            this.listBoxStatus.TabIndex = 2;
            this.listBoxStatus.DoubleClick += listBoxStatus_DoubleClick;

            // 
            // btnOK
            // 
            this.btnOK.Location = new System.Drawing.Point(306, 290);
            this.btnOK.Name = "btnOK";
            this.btnOK.Size = new System.Drawing.Size(75, 30);
            this.btnOK.TabIndex = 3;
            this.btnOK.Text = "确定";
            this.btnOK.UseVisualStyleBackColor = true;
            this.btnOK.Click += btnOK_Click;

            // 
            // btnCancel
            // 
            this.btnCancel.DialogResult = DialogResult.Cancel;
            this.btnCancel.Location = new System.Drawing.Point(387, 290);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(75, 30);
            this.btnCancel.TabIndex = 4;
            this.btnCancel.Text = "取消";
            this.btnCancel.UseVisualStyleBackColor = true;

            // 
            // DeviceStatusSelectionDialog
            // 
            this.AcceptButton = this.btnOK;
            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
            this.AutoScaleMode = AutoScaleMode.Font;
            this.CancelButton = this.btnCancel;
            this.ClientSize = new System.Drawing.Size(474, 332);
            this.Controls.Add(this.btnCancel);
            this.Controls.Add(this.btnOK);
            this.Controls.Add(this.listBoxStatus);
            this.Controls.Add(this.lblDescription);
            this.Controls.Add(this.lblTitle);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "DeviceStatusSelectionDialog";
            this.StartPosition = FormStartPosition.CenterParent;
            this.Text = "设备状态模拟";
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private void LoadStatusData()
        {
            // 添加各种设备状态选项
            listBoxStatus.Items.Add("1. 设备正常状态 (运行状态: 等待, 报警状态: 正常)");
            listBoxStatus.Items.Add("2. 设备正在取样 (运行状态: 正在取样, 报警状态: 正常)");
            listBoxStatus.Items.Add("3. 设备停止取样 (运行状态: 停止取样, 报警状态: 正常)");
            listBoxStatus.Items.Add("4. 设备首次加药 (运行状态: 首次加药, 报警状态: 正常)");
            listBoxStatus.Items.Add("5. 设备正在滴定 (运行状态: 正在滴定, 报警状态: 正常)");
            listBoxStatus.Items.Add("6. 设备正在清洗 (运行状态: 正在清洗, 报警状态: 正常)");
            listBoxStatus.Items.Add("7. 设备无水或无试剂报警 (运行状态: 等待, 报警状态: 无水或无试剂)");
            listBoxStatus.Items.Add("8. 设备水样没清洗干净报警 (运行状态: 等待, 报警状态: 水样没清洗干净)");
            listBoxStatus.Items.Add("9. 设备加药时长超时报警 (运行状态: 等待, 报警状态: 加药时长超时)");
            listBoxStatus.Items.Add("10. 设备检测异常报警 (运行状态: 等待, 报警状态: 检测异常)");
            listBoxStatus.Items.Add("11. 设备试剂不足报警 (运行状态: 等待, 报警状态: 试剂不足)");
            listBoxStatus.Items.Add("12. 设备通讯异常报警 (运行状态: 等待, 报警状态: 通讯异常)");
        }

        private void listBoxStatus_DoubleClick(object sender, EventArgs e)
        {
            if (listBoxStatus.SelectedIndex >= 0)
            {
                btnOK_Click(sender, e);
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (listBoxStatus.SelectedIndex >= 0)
            {
                SelectedStatus = listBoxStatus.SelectedItem.ToString();
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                MessageBox.Show("请选择一个设备状态！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
    }
}